Cross-building with Scala 3 - #443
Conversation
82dd4ca to
cdf6ef0
Compare
cdf6ef0 to
9308a4a
Compare
| .settings(commonCrossDependencies) | ||
| .settings( | ||
| scalaVersion := "3.0.0-M3", | ||
| crossScalaVersions := Seq("2.12.11", "2.13.2", "3.0.0-M3") |
There was a problem hiding this comment.
I guess we could use the latest versions for Scala 2.12 and 2.13:
- 2.12.13
- 2.13.5
33f2d0a to
0b723c4
Compare
|
I've updated the 2 scala versions. I've tried to find workarounds to get the build to pass, but haven't settled on anything satisfactory. It looks like at this stage we still have too many dependencies that aren't published for scala 3. |
|
Hi @benderpremier , thanks for helping with the Scala 3 migration! Some comments:
Again, thanks! |
|
Thanks for the feedback @juanpedromoreno.
It is cross compiled for scala 3 on the JVM, but not for scala 3 on scalaJS. For the moment I've disabled cross compilation on scalaJS with. lazy val fetchJS = fetch.js
.disablePlugins(ScoverageSbtPlugin)
.settings(crossScalaVersions := scala2Versions)
I think we do here (on line 9). It generates the table of content that we see in the
Yes I think it makes sense. I'll only compile this project with
If everyone is happy with that let's do it 💪. |
|
I've removed the code coverage plugins and adapted the build. I think if we want to publish for |
|
@benderpremier @franciscodr Some Scala3 porting projects will trigger some (significant) code-refactoring. It would be good to have this. Can we merge this and publish a new version (1.4.3)? Question: Am I right to assume that |
| # Fetch | ||
|
|
||
| [](https://gitter.im/47deg/fetch?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](http://codecov.io/github/47deg/fetch?branch=master) [](https://oss.sonatype.org/#nexus-search;gav~com.47deg~fetch*) [](https://raw.githubusercontent.com/47deg/fetch/master/LICENSE) [](https://index.scala-lang.org/47deg/fetch) [](http://scala-js.org) [](https://github.com/47deg/fetch/issues) | ||
| [](https://gitter.im/47deg/fetch?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) (http://codecov.io/github/47deg/fetch?branch=master) [](https://oss.sonatype.org/#nexus-search;gav~com.47deg~fetch*) [](https://raw.githubusercontent.com/47deg/fetch/master/LICENSE) [](https://index.scala-lang.org/47deg/fetch) [](http://scala-js.org) [](https://github.com/47deg/fetch/issues) |
There was a problem hiding this comment.
You removed half of the codecov badge but left (http://codecov.io/github/47deg/fetch?branch=master) - is that intentional?
There was a problem hiding this comment.
That wasn't intentional. I'll fix it 👍 .
| } | ||
|
|
||
| } | ||
| ///* |
There was a problem hiding this comment.
What's the plan for this file? Should we delete it instead of commenting it out?
There was a problem hiding this comment.
I have uncommented all examples and only cross-compile them for scala2 versions. I assume we can wait until all libraries we depend on in the examples are published for scala3 to cross-compile the examples to scala3 as well.
| ): BlockedRequest[F] = | ||
| (x.request, y.request) match { | ||
| case (a @ FetchOne(aId, ds), b @ FetchOne(anotherId, _)) => | ||
| case (a: FetchOne[Any, Any], b: FetchOne[Any, Any]) => |
There was a problem hiding this comment.
This is a bit unfortunate. I can't claim to fully understand all this code, but as far as I can tell, it was taking advantage of bugs in the Scala compiler's GADT support in order to compile?
I had a quick look but I have a feeling that any attempt to address this properly would become a rewrite of most of the library. We could at least try to suppress the erasure warnings?
There was a problem hiding this comment.
Something we can try if the @ operator doesn't work is to rewrap the pattern again if needed?
case (FetchOne(aId, ds), FetchOne(anotherId, ds2)) =>
val a = FetchOne(aId, ds)
val b = FetchOne(anotherId, ds2)There was a problem hiding this comment.
I tried that but I am getting the same compilation error:
[error] -- [E007] Type Mismatch Error: /Users/damien/code/fetch/fetch/src/main/scala/fetch.scala:167:48
[error] 167 | val combined = combineIdentities(a, b)
[error] | ^
[error] | Found: (b : fetch.package.FetchOne[I$2, A$2])
[error] | Required: fetch.FetchQuery[I$1, A$1]
The compiler wants to prove that the type parameters of FetchOne a and b are the same but it can't. We lose those parameters when we use FetchRequest.
There was a problem hiding this comment.
I'll try to see if we can keep track of the I and A type params along the way. I gave it a quick go now and it doesn't seem so straightforward.
There was a problem hiding this comment.
I spent some time this afternoon trying to keep track of the I and avoid the FetchOne[Any, Any]. However, I end up bubbling that type parameter all the way up in the API (in the pure and apply method of the Fetch object) which I don't think we want to do.
I am not sure there is a way around using Any here. If you look at how the Fetch are created, we widen to Any in the fetch constructor methods (apply, optional) and then cast with asInstanceOf[A]. Looks like this is where we loose the I we would need here.
Also the monad instance for fetch, implicit def fetchM[F[_]: Monad]: Monad[Fetch[F, *]] would have to be reworked if we push the I all the way up which seems complicated.
pepegar
left a comment
There was a problem hiding this comment.
This looks great Damian,
My only concern is the pattern matches in which we're matching patterns using the pat: Type form instead of capturing the match in a varialbe with v @ Type, we loose type safety that way.
Also, for HTTP4s, I think you can use one of the milestonre releases like 1.0.0-M1 (https://mvnrepository.com/artifact/org.http4s/http4s-dsl_2.13/1.0.0-M19) that crossbuilds for scala 3.0.0-RC1
|
Thanks for all the reviews!!! (cc: @benderpremier @franciscodr) |
|
@benderpremier I am interested to get this merged/published. Let me know, if/how I can help. |
|
I am not sure how we want to move forward with this. I agree that having the
|
juanpedromoreno
left a comment
There was a problem hiding this comment.
I'd suggest opening an issue for the FetchOne[Any, Any] improvement, and try to move this forward.
LGTM, thanks @benderpremier !
|
@benderpremier I agree with @juanpedromoreno: Would suggest to merge now and create a followup ticket to work on |
|
@juanpedromoreno I had to update to scala3 RC2. After merging master into this branch, scalatest got updated to 3.2.7 which is only published for RC2. Could you give it a ✅ ? |
Closes #439
Draft PR to cross build for scala 3
:instead of extractor@Caveats:
fetchJStests do not compile for scala 3 as scalatest isn't published for scalaJS with scala 3 ( https://mvnrepository.com/artifact/org.scalatest/scalatest )fetch-examplehttp4s isn't published for scala 3 yet.fetch-examplemonix isn't published for scala 3 yet.sbt-mdoc-tocsbt plugin isn't published for scala 3 yet. I thinksbt-mdoc-toctransitively depends onmdocbeing ready for scala3. According to this issue, it is currently published for scala3 but only to allow worksheet supportsbt-scoverageisn't published for scala 3 yet. (See this issue